<?php
namespace Usuarios\Model;

use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;

class Funcionario implements InputFilterAwareInterface {

   public $id;
   public $fecha_ingreso;
   protected $inputFilter;

   public function setId($i) {
      $this->id = $i;
   }

   public function setFechaIngreso($fecha) {
      $this->fecha_ingreso = $fecha;
   }

   public function exchangeArray($data) {
      $this->id            = (isset($data['id'])) ? $data['id'] : null;
      $this->fecha_ingreso = (isset($data['fecha_ingreso'])) ? $data['fecha_ingreso'] : null;
   }

   public function getArrayCopy() {
      return get_object_vars($this);
   }

   public function setInputFilter(InputFilterInterface $inputFilter) {
      throw new \Exception("Not used");
   }

   public function getInputFilter() {
      if (!$this->inputFilter) {
         $inputFilter = new InputFilter();
         $factory     = new InputFactory();

         $inputFilter->add($factory->createInput(array(
            'name'     => 'id',
            'required' => true,
            'filters'  => array(
               array('name' => 'Int'),
            ),
         )));

         $inputFilter->add($factory->createInput(array(
            'name'     => 'fecha_ingreso',
            'required' => true,
            'filters'  => array(
               array('name' => 'StripTags'),
               array('name' => 'StringTrim'),
            ),
            'validators' => array(
               array(
                  'name' => 'StringLength',
                  'options' => array(
                     'encoding' => 'UTF-8',
                     'min' => 1,
                     'max' => 24,
                  ),
               ),
            ),
         )));

         $this->inputFilter = $inputFilter;
      }

      return $this->inputFilter;
   }
}
